package com.hnit.camellia.service.impl;
import com.hnit.camellia.entity.Address;
import com.hnit.camellia.mapper.AddressMapper;
import com.hnit.camellia.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    AddressMapper addressMapper;

    /**
     * 根据默认地址查询
     * @return
     */
    @Override
    public Address getAddressByDefault() {
        return addressMapper.getAddressByDefault();
    }

    /**
     * 查询所有地址
     * @return
     */
    @Override
    public List<Address> getAddressList() {
        return addressMapper.getAddressList();
    }


    /**
     * 删除地址
     * @param id
     */
    @Override
    public void deleteAddress(Integer id) {
        addressMapper.deleteById(id);
    }


    /**
     * 修改地址
     *
     * @param address
     */
    @Override
    public void updateAddress(Address address) {
        addressMapper.updateById(address);
    }


    /**
     * 新增地址
     * @param address
     */
    @Override
    public void addAddress(Address address) {
        addressMapper.addAddress(address);
    }
}
